package com.wishu.finance.controller;

import org.activiti.engine.HistoryService;
import org.activiti.engine.RepositoryService;
import org.activiti.engine.RuntimeService;
import org.activiti.engine.TaskService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping("actTiViTi")
public class ActivitiController {
    //历史
    @Resource
    HistoryService historyService;
    //任务
    @Resource
    TaskService taskService;
    //启动
    @Resource
    RuntimeService runtimeService;
    //部署
    @Resource
    RepositoryService repositoryService;

    @RequestMapping("repository")
    public void repository() {
        repositoryService.createDeployment()
                .addClasspathResource("hetong/hetong.bpmn20.xml")
                .addClasspathResource("hetong/diagram.png")
                .name("合同审批");
    }

    @RequestMapping("runTime")
    public void runTime() {
        runtimeService.startProcessInstanceByKey("hetong");
    }
}
